<template>
    <div class="main apply-report pr">
        <apply-header v-show="showHeader" :orderInfo="this.orderInfoMsg"></apply-header>
        <div class="fixedTab">
            <!-- <Row class="btns">
                <Col offset="19">
                    <Button type="primary" @click="applyBatchPrint">模板生成</Button>
                    <Button type="primary" @click="downloadFile">申请书下载</Button>
                    <Button type="primary" @click="submitSave" v-show="!isShowDetails">保存</Button>
                    <Button type="primary" @click="checkFileMethed()"
                            v-show="!isShowDetails">提交
                    </Button>
                    <Button type="primary" v-show="diffType!='add'" @click="backOrder">返回</Button>
                </Col>
            </Row> -->
            <ul class="title_text">
                <li v-for="(item,index) in tabsType" :key="index" :class="{active:curTab===index}"
                    @click="toggle(index)">
                    <!-- <p><img :src="item.imgSrc" alt=""></p> -->
                    <span>{{item.value}}</span>
                </li>
            </ul>
        </div>
        <div class="specific_field" style="background-color:white;padding-top: 20px;">
            <div v-show="curTab===0">
                <business-option
                    ref="businessOption"
                    @deliverApplayNo="getApplyNo"
                    :curTab="curTab"
                    :isReconsider="isReconsider"
                    :preId="preId"
                    :isShowDetails="isShowDetails"
                    :remarkForm="remarkForm"
                    @isLoading="isLoading"
                    @vehicleAuth="vehicleAuth"
                    @valiateSelectRes="valiateSelectRes"
                    @optionCallSuccess="optionCallSuccess"
                    :diffType='diffType'
                ></business-option>
            </div>
            <div v-show="curTab===1">
                <custom-info
                    ref="customInfo"
                    :applyNo="applyNo"
                    :curTab="curTab"
                    :isShowDetails="isShowDetails"
                    :tempBusinessType="tempBusinessType"
                    @isLoading="isLoading"
                    :remarkForm="remarkForm"
                    :isOldCarDisabled="isOldCarDisabled"
                    :isNewCarDisabled="isNewCarDisabled"
                    :channelObj="channelObj"
                    :preId="preId"
                    @valiateCustomRes="valiateCustomRes"
                    @customCallSuccess="customCallSuccess"
                ></custom-info>
            </div>
            <div v-show="curTab===2">
                <financial-prod
                    :additionalProessForm="additionalProessForm"
                    :proessForm="proessForm"
                    :carProessForm="carProessForm"
                    :isShowDetails="isShowDetails"
                    :isReconsider="isReconsider"
                    ref="financialProd"
                    @isShowModel="isShowModel"
                    :saveStatus="saveStatus"
                    @scheduleTitle="scheduleTitle"
                    @showCalculate="showCalculate"
                    :uuid="uuid"
                    :intropath="intropath"
                    :curTab="curTab"
                    :applyNo="applyNo"
                    @caluMaxValue="caluMaxValue"
                    @passValiate="passValiate"
                    :remarkForm="remarkForm"
                    :queryFormEl="queryFormEl"
                    @valiateProRes="valiateProRes"
                    @proCallSuccess="proCallSuccess"
                >
                    <template slot="afsApply">
                        <div>
                            <div class="submit">
                                <Button type="primary" @click="calculate" style="width: 100px;height: 30px;">计算</Button>
                                <Button type="primary" style="margin-left: 30px;width: 100px;height: 30px;"
                                        @click="financialSave" :disabled="saveStatus.disabled" v-if="!isShowDetails">保存
                                </Button>
                            </div>
                            <Modal width="50%" v-model="proessModel" :footer-hide="true" @on-cancel="cancelModel">
                                <div class="scheduleTitle">
                                 <span v-for="(item,index) in scheduleTitleList" @click="tagTitle(item.value)"
                                       :class="{curScheStyle:curSchedule===item.value}">
                                     {{item.title}}
                                 </span>
                                </div>
                                <div class="sliderList">
                                    <div>
                                        <Form ref="proessForm" :model="proessForm" :rules="proessFormValidate"
                                              :label-width="140" v-show="curSchedule=='00'">
                                            <Row v-for="(item,index) in proessForm.proessList" :key="index"
                                                 style="padding: 0px 30px;">
                                                <Col :span="2">
                                                    <div style="padding-top: 8px;">
                                                        {{item.no}}<span>期</span>
                                                    </div>
                                                </Col>
                                                <Col :span="5">
                                                    <FormItem label="" :prop="'proessList['+index+'].inputValue'"
                                                              class="inline-block mb10" :label-width="0">
                                                        <Input v-model="item.inputValue" placeholder=""
                                                               @on-blur="getInputValue(item.inputValue,index,isreadonly)"
                                                               :readonly="isreadonly||isShowDetails"
                                                               style="width: 100%;"
                                                        />
                                                    </FormItem>
                                                </Col>
                                                <Col :span="16" offset="1">
                                                    <Slider :value="item.proessValue" range :disabled="true"
                                                            :max="maxValue" :step="stepNumber"></Slider>
                                                </Col>
                                            </Row>
                                        </Form>
                                        <Form ref="carProessForm" :model="carProessForm" :label-width="140"
                                              v-show="curSchedule=='01'">
                                            <Row v-for="(item,index) in carProessForm.proessList" :key="index"
                                                 style="padding: 0px 30px;">
                                                <Col :span="2">
                                                    <div style="padding-top: 8px;">
                                                        {{item.no}}<span>期</span>
                                                    </div>
                                                </Col>
                                                <Col :span="5">
                                                    <FormItem label="" class="inline-block mb10" :label-width="0">
                                                        <Input v-model="item.inputValue" placeholder=""
                                                               :readonly="isreadonly"
                                                               style="width: 100%;"
                                                        />
                                                    </FormItem>
                                                </Col>
                                                <Col :span="16" offset="1">
                                                    <Slider :value="item.proessValue" range :disabled="true"
                                                            :max="maxValue" :step="stepNumber"></Slider>
                                                </Col>
                                            </Row>
                                        </Form>
                                        <Form ref="additionalProessForm" :model="additionalProessForm"
                                              :label-width="140" v-show="curSchedule=='02'">
                                            <Row v-for="(item,index) in additionalProessForm.proessList" :key="index"
                                                 style="padding: 0px 30px;">
                                                <Col :span="2">
                                                    <div style="padding-top: 8px;">
                                                        {{item.no}}<span>期</span>
                                                    </div>
                                                </Col>
                                                <Col :span="5">
                                                    <FormItem label="" class="inline-block mb10" :label-width="0">
                                                        <Input v-model="item.inputValue" placeholder=""
                                                               :readonly="isreadonly"
                                                               style="width: 100%;"
                                                        />
                                                    </FormItem>
                                                </Col>
                                                <Col :span="16" offset="1">
                                                    <Slider :value="item.proessValue" range :disabled="true"
                                                            :max="maxValue" :step="stepNumber"></Slider>
                                                </Col>
                                            </Row>
                                        </Form>
                                    </div>
                                </div>
                                <div v-if="isShowCalculate&&!isShowDetails" style="text-align: center;margin:0px;"
                                     class="submit">
                                    <Button @click="calculateIntrate" type="primary" style="width: 100px;height: 30px;">
                                        计算
                                    </Button>
                                </div>
                            </Modal>
                        </div>
                    </template>
                </financial-prod>
            </div>

        </div>
        <div v-if="curTab===3">
            <file-operation v-if="isInt&&showFile"
                            :uploadParam="uploadParam"
                            :readOnly="readOnly"
                            :isInt="isInt"
                            :path="path"
            >
            </file-operation>
        </div>
        <!-- 备注 -->
        <div class="remarkForm">
            <div v-if="curTab==0||curTab==2||(curTab==3&&isInt&&showFile)">
                <h2 class="extra_title" style="font-size: 14px;">备注</h2>
                <Form ref="remarkForm" :model="remarkForm" :label-width="curTab==0?140:100" :rules="remarkFormValidate">
                    <div class="common_br">
                        <div class="common_content">
                            <Row>
                                <Col span="16">
                                    <FormItem label="备注" prop="remark">
                                        <Input v-model="remarkForm.remark" placeholder="请输入备注" type="textarea"
                                               style="width: calc(100% + 340px);"
                                               :disabled="isShowDetails||isReconsider||isRemark"/>
                                    </FormItem>
                                </Col>
                            </Row>
                        </div>
                    </div>
                </Form>
            </div>
            <div v-if="curTab==1">
                <Collapse v-model="openPanel" simple>
                    <Panel name="1">
                        <span>备注</span>
                        <div slot="content">
                            <Form ref="remarkForm" :model="remarkForm" :label-width="curTab==0?140:100"
                                  :rules="remarkFormValidate">
                                <div class="common_br">
                                    <div class="common_content">
                                        <Row>
                                            <Col span="16">
                                                <FormItem label="备注" prop="remark">
                                                    <Input v-model="remarkForm.remark" placeholder="请输入备注"
                                                           type="textarea"
                                                           style="width: calc(100% + 340px);"
                                                           :disabled="isShowDetails||isReconsider||isRemark"/>
                                                </FormItem>
                                            </Col>
                                        </Row>
                                    </div>
                                </div>
                            </Form>
                        </div>
                    </Panel>
                </Collapse>
            </div>
        </div>
        <div class="footer">
            <div class="footer_content">
                <p v-show="curTab===0">
                    <Button type="primary" @click="nextCustom">下一步 客户信息</Button>
                    <Button type="primary" v-if="$store.getters.permissions['apply_submit_button']"  class="submitBtn" @click="checkFileMethed()"
                            v-show="!isShowDetails">提交
                    </Button>
                </p>
                <p v-show="curTab===1">
                    <Button type="primary" @click="nextFinanceProd">下一步 金融产品</Button>
                    <Button type="primary"  v-if="$store.getters.permissions['apply_submit_button']"  class="submitBtn" @click="checkFileMethed()"
                            v-show="!isShowDetails">提交
                    </Button>
                </p>
                <p v-show="curTab===2">
                    <Button type="primary" @click="nextFile">下一步 影像资料</Button>
                    <Button type="primary"  v-if="$store.getters.permissions['apply_submit_button']"  class="submitBtn" @click="checkFileMethed()"
                            v-show="!isShowDetails">提交
                    </Button>
                </p>
                <p v-show="curTab==3">
                    <Button type="primary"  v-if="$store.getters.permissions['apply_submit_button']"  v-show="!isShowDetails"
                            @click="checkFileMethed()">提交
                    </Button>
                </p>
            </div>
        </div>
        <!-- 留言模块 -->
        <div class="leaveComments">
            <div class="fade_commonent" :class="moveComment?'noWidth':'defaultWidth'">
                <div class="detail_comment" :class="moveComment?'hiddenClass':'defaultClass'">
                    <h2>留言
                        <Icon type="ios-close" @click="closeComment"/>
                    </h2>
                    <ul>
                        <li v-for="(item,index) in remindList" class="mt10 pr" style="min-height: 67px;">
                            <div v-if="item.isSelf=='0'">
                                <div class="inline-block">{{item.createBy}}
                                    <p class="other">
                                        {{item.msgContent}}
                                    </p>
                                </div>
                                <span style="left:100px" class="abs">{{item.createTime}}</span>
                            </div>
                            <div v-if="item.isSelf=='1'">
                                <div class="inline-block fr" style="margin-right: 10px;text-align: right;">
                                    {{item.createBy}}
                                    <p class="self">
                                        {{item.msgContent}}
                                    </p>
                                </div>
                                <span style="right:100px" class="abs">{{item.createTime}}</span>
                            </div>
                        </li>
                    </ul>
                    <div class="textarea">
                        <Input v-model="comment" type="textarea" placeholder="请输入留言" class="inline-block"
                               style="width: 85%;" maxlength="120"/>
                        <!-- <Button type="primary" @click="saveRemind" class="fr" :disabled="isDisabled">保存</Button> -->
                        <div @click="saveRemind" class="fr" style="height: 20px;margin-top:10px"><img
                            src="../../../assets/img/fasong.jpg" alt=""/></div>
                    </div>
                </div>
            </div>
            <div class="tapImg" v-if="remindList.length>0">
                <img src="../../../assets/img/msg.png" alt="" @click="tagImage">
            </div>
        </div>
        <Spin size="large" fix v-if="loading"></Spin>
        <Modal title="文件模版" v-model="templateModel" :mask-closable='false' width="60%">
            <div class="roleCheckGroup">
                <div>
                    <Button class="allBtn">
                        <Checkbox
                            :indeterminate="indeterminate"
                            :value="checkAll"
                            class="checkAll"
                            @click.prevent.native="handleCheckAll">
                            全部
                        </Checkbox>
                    </Button>
                    <Button @click="downloadBatchFile(fileList)">批量下载</Button>
                </div>
                <div>
                    <CheckboxGroup v-model="checkAllGroup" @on-change="checkAllGroupChange">
                        <Row v-for="(item,index) in fileList" style="padding: 5px 0px">
                            <Col span="11" offset="1">
                                <Checkbox
                                    :label="item.attachmentCode"
                                    :key="item.attachmentCode"
                                    style="margin-top: 3px;" @click="getAttachmentData">
                                    <span>{{item.attachmentName}}</span>
                                </Checkbox>
                            </Col>
                            <Col span="4">
                                <Button>业务类型标签</Button>
                            </Col>
                            <Col span="4">
                                <!-- <Button>打印预览</Button> -->
                                <Button @click="pdfPreview(item)">预览</Button>
                            </Col>
                            <Col span="4">
                                <Button @click="downloadSingleFile(item)">下载</Button>
                            </Col>
                        </Row>
                    </CheckboxGroup>
                </div>
            </div>
        </Modal>
        <div class="fixed_nav">
            <ul>
                <!-- <li v-show="showSave">
                    <img src="../../../assets/img/save@2x.png" alt="">
                    <span>暂存</span>
                </li> -->
                <li @click="applyBatchPrint">
                    <!--                <li @click="downloadFile">-->
                    <img src="../../../assets/img/write@2x.png" alt="">
                    <span>协议下载</span>
                </li>
                <li @click="tagConsult">
                    <img src="../../../assets/img/consult@2x.png" alt="">
                    <span>咨询</span>
                    <div class="login-qr-box" v-show="isShowConsult">
                        <div class="login-qr">
                            <div>
                                <span style="font-size:14px;color:#333333">客服电话</span>
                                <p style="border-bottom: 1px solid #D8D8D8;margin:2px 0 10px;padding-bottom: 10px;">
                                    <span style="color:#666;margin-top: 4px;">400-6527-606</span> <span
                                    style="color:#999">( 8:30-17:30 )</span></p>
                            </div>
                            <div class="qr">
                                <span style="font-size:14px;color: #333;"> 客服QQ </span>
                                <img src="../../../assets/img/qq_apply@2x.png" style="display: block;">
                            </div>
                            <div class="qr-title" style="padding-top: 0;text-align: center;">
                                <span style="font-size:12px">QQ:1001001000</span>
                            </div>
                            <div class="qq-btn" style="text-align: center;">
                                <Button type="primary">立即QQ咨询</Button>
                            </div>
                        </div>
                    </div>
                </li>
                <!-- <li >
                    <img src="../../../assets/img/down@2x.png" alt="">
                    <span>下载</span>
                </li> -->
                <li>

                    <a href="javascript:scrollTo(0,0);">
                        <img src="../../../assets/img/up@2x.png" alt="">
                        置顶</a>
                </li>
            </ul>
        </div>
    </div>
</template>
<script>
    import "../../../assets/css/base.css";
    import BusinessOption from "./business-option/businessOption.vue";
    import ApplyHeader from "../common/apply-header.vue";
    import CustomInfo from "./custom-info/customInfo.vue";
    import FinancialProd from "@/components/financial-prod";
    import FileOperation from "_p/basic/pages/image/upload-file/fileOperation.vue";
    import utils from "@/libs/util.js";
    import * as applyUtils from '_p/afs-apply/assets/js/utils.js'
    import {getRemindList, savaRemindDetails} from '_p/afs-apply/api/apply-report/personal/common.js'
    import {getFilterParams, submitCaseInfo} from "../../../api/apply-report/personal/common";
    import {checkFile,} from "_p/basic/api/image/image-upload";
    import {
        applyBatchPrint,
        downloadBatchFile,
        downloadSingleFile,
        getComAttach
    } from "../../../api/contract/corporate/corporateTransferManagement";
    import {queryAllInfo} from "_p/afs-apply/api/apply-contract/contract/entry/contract-entry";
    import {getUserInfo} from "../../../../basic/api/admin/user";
    import {deepClone} from "@/libs/utils/ObjectClone";
    import {
        getOrderInfo
    } from '_p/afs-apply/api/apply-report/personal/businessOption.js'

    export default {
        name: "apply_main",
        data() {
            return {
                isReconsider: false,
                isRemark: false,
                curIndex: "",
                showSave: true,
                openPanel: "1",
                readOnly: false,
                isShowConsult: false,
                showHeader: false,
                preData: {},
                preId: "",
                orderInfoMsg: {},
                isOldCarDisabled: "",
                isNewCarDisabled: "",
                channelObj: {},
                showFile: true,
                isSubmit: false,
                sellerPhone: '',
                sellerRealName: '',
                path: "apply",
                curTab: 0,
                loading: false,
                moveComment: true,
                isDisabled: true,
                templateModel: false,
                indeterminate: false,
                checkAll: false,
                isInt: false,
                comment: "",
                applyNo: "",
                applyStatus: "",
                uuid: "",
                signResult: "",
                diffType: "add",
                isShowDetails: false,
                tempBusinessType: "",
                remindList: [],
                checkAllGroup: [],
                fileList: [
                    {
                        id: "",
                        createBy: "",
                        createTime: "",
                        delFlag: "",
                        busiNo: "",
                        attachmentCode: "",
                        attachmentName: "",
                        fileStatus: "",
                        fileType: "",
                        fileName: "",
                        fileId: "",
                        uploadTime: ""
                    },
                    {
                        id: "",
                        createBy: "",
                        createTime: "",
                        delFlag: "",
                        busiNo: "",
                        attachmentCode: "",
                        attachmentName: "",
                        fileStatus: "",
                        fileType: "",
                        fileName: "",
                        fileId: "",
                        uploadTime: ""
                    }
                ],
                uploadParam: {
                    busiNo: "",
                    belongNo: "",
                    busiType: "",
                    busiData: {}
                },
                tabsType: [
                    {
                        value: "业务选择",
                        imgSrc: require("_p/afs-apply/assets/img/apply_icon1.png"),
                    },
                    {
                        value: "客户信息",
                        imgSrc: require("_p/afs-apply/assets/img/apply_icon2.png"),
                    },
                    {
                        value: "金融产品",
                        imgSrc: require("_p/afs-apply/assets/img/apply_icon3.png"),
                    },
                    {
                        value: "影像上传",
                        imgSrc: require("_p/afs-apply/assets/img/apply_icon3.png"),
                    }
                ],
                remarkForm: {
                    remark: "",
                },
                remarkFormValidate: {
                    remark: []
                },
                stepNumber: 0.01,
                maxValue: 800,
                saveStatus: {
                    disabled: true,
                    noData: true,
                    ismodify:false,
                },
                proessModel: false,
                isShowCalculate: false,
                additionalProessForm: {
                    proessList: [],
                },
                proessFormValidate: {},
                proessForm: {
                    proessList: [],
                },
                carProessForm: {
                    proessList: [],
                },
                scheduleTitleList: [],
                curSchedule: "00",
                intropath: "afsApply",
                isreadonly: true,
            }
        },
        // provide () {
        //     return {
        //         curTab: this.curTab,
        //     }
        // },
        components: {
            BusinessOption,
            CustomInfo,
            // FinancialProducts,
            FinancialProd,
            FileOperation,
            ApplyHeader
        },
        created() {
            if (this.afs.getPageParams(this)) {
                this.applyNo = this.afs.getPageParams(this).applyNo;
                this.applyStatus = this.afs.getPageParams(this).applyStatus;
                this.diffType = this.afs.getPageParams(this).diffType;
                this.preId = this.afs.getPageParams(this).preId;
                this.signResult = this.afs.getPageParams(this).signResult;
                this.preData = this.afs.getPageParams(this).data;
            }
            // let flag = this.$route.params.flag;
            // if (flag != 'new' && typeof (flag) != "undefined") {
            //     this.getFilterParams();
            // }
            if (this.remarkForm.remark != '') {
                this.isRemark = true;
            }
            if (this.applyNo != null || this.applyNo != '' || typeof (this.applyNo) != 'undefined') {
                this.getFilterParams();
            }
            if (this.applyStatus != '' && this.applyStatus == '12') {
                this.isReconsider = true;
            }
            if (this.afs.getPageParams(this)&&this.afs.getPageParams(this).flag !== "new") {
                this.showHeader = true;
            }
            if (this.diffType !== "details") {
                this.isShowDetails = false;
                this.showSave = true;
            } else {
                this.showSave = false;
                this.readOnly = true;
                this.isShowDetails = true;
            }
            this.uuid = this.getUuid();
        },
        mounted() {
            this.queryRemind();
            this.initGteUserInfo();
            this.queryOrderInfo();

        },
        // 离开当前页面(路由)
        // beforeRouteLeave(to, form, next) {
        //     sessionStorage.removeItem('storeApplyNo')
        // },
        methods: {
            tagConsult() {
                this.isShowConsult = !this.isShowConsult;
            },
            vehicleAuth(newCarDisabled, oldCarDisabled, channelObj) {
                this.isNewCarDisabled = newCarDisabled;
                this.isOldCarDisabled = oldCarDisabled;
                this.channelObj = channelObj;
            },
            queryOrderInfo() {
                let param = {applyNo: this.applyNo};
                getOrderInfo(param).then(res => {
                    if (res.code == "0000") {
                        if (res.data) {
                            this.orderInfoMsg = res.data;
                            console.log(res.data, "备注")
                            if (res.data.remarks !== '' && res.data.remarks != null && res.data.remarks != undefined) {
                                console.log("进来了")
                                this.isRemark = true;
                            } else {
                                this.isRemark = false;
                            }
                        }
                    }
                });
            },
            //初始化获得用户信息
            initGteUserInfo() {
                getUserInfo().then(res => {
                    if (res.code === '0000') {
                        let userExtInfo = res.data.userExtInfo;
                        let roleList = res.data.roleList;
                        for (let i = 0; i < roleList.length; i++) {
                            if (roleList[i].roleCode === 'ROLE_XCRECORDED' || roleList[i].roleCode === 'ROLE_RECORDED') {
                                this.isSubmit = true;
                            }
                        }
                        let sysUser = res.data.sysUser;
                        this.sellerPhone = res.data.sysUser.phone;
                        this.sellerRealName = res.data.sysUser.userRealName;
                        this.deptId = deepClone(sysUser.deptId);
                        this.roleCode = deepClone(userExtInfo.roles[0].roleCode);
                        this.username = sysUser.username;
                    }
                })
            },
            // 查询影像件需要的数据
            getFilterParams() {
                let params = {
                    applyNo: this.applyNo,
                }
                getFilterParams(params).then(res => {
                    if (res.code === '0000') {
                        // console.log(res.data)
                        this.uploadParam.busiNo = this.applyNo;
                        this.uploadParam.belongNo = this.applyNo;
                        this.uploadParam.busiData = res.data;
                        this.uploadParam.busiType = "orderApply";
                        this.isInt = true;
                    }
                })
            },

            isLoading(val) {
                this.loading = val;
            },
            getUuid() {
                let seed = 0;
                const now = Date.now();
                return 'ui-tab-' + now + '-' + (seed++);
            },
            // tab切换事件校验表单
            toggle(index) {
                // 当不是详情的时候校验
                this.curIndex = index;
                if (this.diffType != "details") {
                    if (this.curTab != index) {
                        if (this.curTab == 0) {
                            this.$refs.businessOption.finallySubmitData('cutTable');
                        }
                        if (this.curTab == 1) {
                            this.$refs.customInfo.checkCustomInfo('01', 'customInfoForm', 'cutTable')
                        }
                        if (this.curTab == 2) {
                            if (this.saveStatus.noData) {
                                this.$Message.warning("请完善金融产品内容")
                            } else {
                                // 当页面修改过
                                if(this.saveStatus.ismodify){
                                    if (!this.saveStatus.disabled) {
                                        this.$refs.financialProd.financialSave('cutTable');
                                    } else {
                                        this.$Message.warning("先点击计算")
                                    }
                                }else{
                                    this.curTab=index;
                                }
                            }
                        }
                        if (this.curTab == 3) {
                            this.curTab = index;
                        }
                        // if (index == 3) {
                        //     if (this.applyNo != '') {
                        //         this.getFilterParams();
                        //     }
                        // } else {
                        //     this.isInt = false;
                        // }
                        // if (this.curTab == 0) {
                        //     this.$refs.businessOption.validateAll((pass) => {
                        //         if (!pass) {
                        //             this.$Message.warning("数据录入不正确")
                        //             return
                        //         }
                        //         if (this.applyNo) {
                        //             this.curTab = index;
                        //         } else {
                        //             this.$Message.warning("请先保存业务选择内容")
                        //         }
                        //     })
                        //     if (index == 1) {
                        //         this.tempBusinessType = this.$refs.businessOption.deliverBusinessType();
                        //     }
                        // } else {
                        //     this.curTab = index;
                        // }
                    }
                } else {
                    if (this.applyNo != '') {
                        this.getFilterParams();
                    }
                    this.curTab = index;
                }
            },
            optionCallSuccess(result) {
                if (result) {
                    this.curTab = this.curIndex;
                    if (this.curTab == 1) {
                        this.tempBusinessType = this.$refs.businessOption.deliverBusinessType();
                    }
                    this.queryFilterParams(this.curTab)
                }
            },
            customCallSuccess(result) {
                if (result) {
                    this.curTab = this.curIndex;
                    this.queryFilterParams(this.curTab)
                }
            },
            proCallSuccess(result) {
                if (result) {
                    this.curTab = this.curIndex;
                    this.queryFilterParams(this.curTab)
                }
            },
            queryFilterParams(curTab) {
                if (curTab == 3) {
                    if (this.applyNo != '') {
                        this.getFilterParams();
                    }
                }
            },
            // 点击下一步到客户信息
            nextCustom() {
                if (!this.isShowDetails) {
                    this.$refs.businessOption.finallySubmitData('nextBtn');
                } else {
                    this.curTab = 1;
                    this.tempBusinessType = this.$refs.businessOption.deliverBusinessType();
                }
            },
            // 业务选择的校验并保存
            valiateSelectRes(result) {
                if (result) {
                    this.curTab = 1;
                }
            },
            // 点击下一步到金融产品
            nextFinanceProd() {
                if (!this.isShowDetails) {
                    this.$refs.customInfo.checkCustomInfo('01', 'customInfoForm', 'nextBtn')
                } else {
                    this.curTab = 2;
                }
            },
            valiateCustomRes(result) {
                console.log(result, "result")
                if (result) {
                    this.curTab = 2;
                }
            },
            // 点击下一步到影像
            nextFile() {
                if (!this.isShowDetails) {
                    if (!this.saveStatus.disabled) {
                        this.$refs.financialProd.financialSave('nextBtn');
                    } else {
                        this.$Message.warning("先点击计算");
                        return false;
                    }
                } else {
                    this.curTab = 3;
                }

            },
            valiateProRes(res) {
                if (res) {
                    this.curTab = 3;
                    if (this.applyNo != '') {
                        this.getFilterParams();
                    }
                }
            },
            //影像件校验
            checkFileMethed() {
                if (this.uploadParam.busiNo != '') {
                    checkFile(this.uploadParam).then(res => {
                        if (res.code === '0000') {
                            if (this.isSubmit === false) {
                                this.applySubmit();
                            }
                        }
                    });
                }
            },
            initGetComAttach() {
                let params = {
                    busiNo: this.applyNo,
                    // busiNo:"DP-B001948",
                    pageSize: 500,
                    pageNumber: 1,
                    printNode: "printOrderApply"
                }
                getComAttach(params).then(res => {
                    if (res.code === '0000') {
                        this.fileList = res.data.records;
                        if (this.fileList.length > 0) {
                            this.templateModel = true;
                        } else {
                            this.$Message.warning("暂无下载的模版")
                        }
                    }
                })
            },
            applySubmit() {
                let params = {
                    applyNo: this.applyNo,
                    sellerPhone: this.sellerPhone,
                    sellerRealName: this.sellerRealName,
                    remarks: this.remarkForm.remark
                }
                submitCaseInfo(params).then(res => {
                    if (res.code === '0000') {
                        this.$Message.success("申请提交成功")
                        this.afs.closeTab(this)
                    }
                });
            },

            queryFormEl() {
                return this.$refs.proessForm;
            },
            submitSave() {
                if (this.curTab == 0) {
                    this.$refs.businessOption.finallySubmitData();
                } else if (this.curTab == 1) {
                    this.$refs.customInfo.checkCustomInfo('01', 'customInfoForm')
                } else if (this.curTab == 2) {
                    if (!this.saveStatus.disabled) {
                        this.$refs.financialProd.financialSave();
                    } else {
                        this.$Message.warning("先点击计算")
                    }
                } else if (this.curTab == 3) {
                    checkFile(this.uploadParam).then(res => {
                        if (res.code === '0000') {
                            this.$Message.success("影像件已保存")
                        }
                    });
                }
            },
            getApplyNo(applyNo) {
                this.applyNo = applyNo;
                this.afs.setPageParams(this,{applyNo:applyNo});
            },
            tagImage() {
                this.moveComment = !this.moveComment;
            },
            closeComment() {
                this.moveComment = true;
            },
            // 保存留言
            saveRemind() {
                if (!this.comment.trim()) {
                    this.$Message.warning("请先留言");
                    return;
                }
                let curDate = utils.formatDate(new Date(), 'YYYY-MM-DD hh:mm:ss');
                let param = {
                    applyNo: this.applyNo,
                    msgContent: this.comment.trim(),
                    createBy: "admin",
                    createTime: curDate,
                }
                if (!this.applyNo) {
                    this.$Message.warning("请先保存业务选择内容");
                    return;
                }
                savaRemindDetails(param).then(res => {
                    if (res.code == "0000") {
                        this.comment = "";
                        this.queryRemind();
                        this.$Message.success("保存留言成功");
                    }
                })
            },
            // 查询留言
            queryRemind() {
                // console.log(2222)
                let param = {
                    applyNo: this.applyNo,
                }
                getRemindList(param).then(res => {
                    if (res.code == "0000") {
                        this.remindList = res.data;
                    }
                })
            },
            // 返回订单管理
            backOrder() {
                this.afs.closeTab(this);
            },
            calculate() {
                this.$refs.financialProd.calculate();
            },
            calculateIntrate() {
                this.$refs.financialProd.calculateIntrate();
            },
            financialSave() {
                this.$refs.financialProd.financialSave();
            },
            tagTitle(value) {
                this.curSchedule = value;
            },
            cancelModel() {
                this.proessModel = false;
            },
            isShowModel(val) {
                this.proessModel = val;
            },
            scheduleTitle(val) {
                this.scheduleTitleList = val;
            },
            showCalculate(falseVal, trueVal) {
                this.isreadonly = falseVal;
                this.isShowCalculate = trueVal;
            },
            getInputValue(value, index, isreadonly) {
                if (!isreadonly) {
                    if (applyUtils.isTwoDicmal(value)) {
                        this.proessForm.proessList[index].proessValue = [0, ""]
                        this.proessForm.proessList[index].proessValue.splice(1, 1, value);
                    }
                }
            },
            caluMaxValue(maxValue) {
                this.maxValue = maxValue;
            },
            passValiate() {
                this.initProessValiate();
            },
            // 校验附加贷
            initProessValiate() {
                // console.log(this.proessForm.proessList[0], "this.proessForm.proessList")
                for (let i = 0; i < this.proessForm.proessList.length; i++) {
                    this.proessFormValidate["proessList[" + i + "].inputValue"] = [
                        {validator: applyUtils.isTwoDicmalValiate, trigger: "blur"}
                    ];
                }
            },
            //获取点选数据
            getAttachmentData(v) {
                // console.log("点选获取的值:", v);
            },
            //模板生成
            applyBatchPrint() {
                queryAllInfo(this.applyNo).then(res => {
                    if (res.code === '0000') {
                        let params = {
                            applyNo: this.applyNo
                        }
                        applyBatchPrint(params).then(res => {
                            if (res.code === '0000') {
                                this.downloadFile();
                                // this.$Message.success("模板已生成")
                            }
                        })
                    }
                })
            },
            //批量文件下载
            downloadBatchFile(v) {
                let downFileList = [];
                if (this.checkAllGroup.length > 0) {
                    if (v.length > 0) {
                        let tempArr = [];
                        v.forEach((item, index) => {
                            if (this.checkAllGroup.indexOf(item.attachmentCode) != "-1") {
                                tempArr.push(item);
                            }
                        })
                        downFileList = tempArr;
                    }
                } else {
                    this.$Message.warning("请选择文件模版下载");
                    return false;
                }
                let params = {
                    attachmentList: downFileList,
                    applyNo: this.applyNo,
                }
                let self = this;
                downloadBatchFile(params).then(function (response) {
                    if (response.status === 200) {
                        self.afs.downloadFile(response);
                    }
                })
            },
            pdfPreview(item) {
                let pdfurl = `${_AFS_PROJECT_CONFIG.apiUri}/${this.path}/upload/getBlob/pdf/${item.fileId}`;
                window.open(pdfurl);
            },
            //单个文件下载
            downloadSingleFile(item) {
                let params = {
                    id: item.id
                }
                let self = this;
                downloadSingleFile(params).then(function (response) {
                    if (response.status === 200) {
                        self.afs.downloadFile(response);
                    }
                })
            },
            downloadFile() {
                this.initGetComAttach();
            },
            handleCheckAll() {
                if (this.indeterminate) {
                    this.checkAll = false;
                } else {
                    this.checkAll = !this.checkAll;
                }
                this.indeterminate = false;
                if (this.checkAll) {
                    let codeList = this.fileList.map((item, index) => {
                        return item.attachmentCode;
                    })
                    this.checkAllGroup = codeList;
                } else {
                    this.checkAllGroup = [];
                }
            },
            checkAllGroupChange(data) {
                if (data.length === this.fileList.length) {
                    this.indeterminate = false;
                    this.checkAll = true;
                } else if (data.length > 0) {
                    this.indeterminate = true;
                    this.checkAll = false;
                } else {
                    this.indeterminate = false;
                    this.checkAll = false;
                }
            },
        }
    }
</script>
<style scoped lang="less">
    .remarkForm {
        background-color: white;

        .ivu-btn-dashed {
            border-color: #EB9620;
            color: #EB9620;
        }

        /deep/ .ivu-collapse-simple {
            border: none;
        }

        /deep/ .ivu-collapse-item {
            border: none;
        }

        /deep/ .ivu-collapse-header {
            background-color: #F0EEEB;
            font-weight: 500;
            color: #232323;
            font-size: 13px;
            margin: 0 10px;
            height: 35px;
            line-height: 35px;
            padding-right: 10px;
        }

        /deep/ .ivu-collapse .ivu-icon-ios-arrow-forward {
            margin-right: 10px;
        }

        /deep/ .ivu-collapse .ivu-icon-ios-arrow-forward:before {
            content: '';
            display: inline-block;
            width: 7px;
            height: 13px;
            background-repeat: no-repeat;
            background-size: 100%;
            background-image: url("");
        }

        .panel-head-right {
            color: #EB9620;
            font-weight: normal;
            display: inline-block;
            width: 40px;
            text-align: center;
            cursor: pointer;
            line-height: 21px;
            float: right;
            margin-top: 7px;
        }

        .panel-head-right:hover {
            background: rgba(235, 150, 32, 0.25);
        }
    }

    .apply-report {
        min-width: 1200px;
        max-width: 1600px;
        margin: 0 auto 65px;
        padding: 0 15px;
    }

    .apply-report /deep/ .ivu-spin-fix {
        z-index: 999;
        top: -110px;
    }

    .main .btns {
        background-color: white;
        padding: 10px 0 0 0;
    }

    .main .btns button {
        margin-right: 10px;
    }

    .leaveComments {
        position: fixed;
        top: 50%;
        right: 10%;
        transform: translateY(-50%);
        margin-top: 40px;
        z-index: 99;
    }

    .fade_commonent {
        position: relative;
        height: 420px;
        width: 400px;
        overflow: hidden;
        transition: all 2s;
    }

    .noWidth {
        width: 0px;
    }

    .defaultWidth {
        width: 400px;
    }

    .tapImg {
        position: absolute;
        right: -50px;
        top: 50%;
        transform: translateY(-50%);
    }

    .tapImg > img {
        width: 40px;
        cursor: pointer;
    }

    .leaveComments .detail_comment {
        position: absolute;
        background-color: white;
        width: 300px;
        height: 380px;
        box-shadow: 0px 0px 18px #ccc;
        top: 18px;
        transition: left 2s;
        border-radius: 5px;
    }

    .leaveComments .detail_comment > h2 {
        background-color: #EB9620;
        font-weight: normal;
        font-size: 14px;
        color: white;
        padding: 5px 0px 5px 10px;
        line-height: 25px;
        border-radius: 5px 5px 0 0;
        position: relative;
    }

    .leaveComments .detail_comment > h2 > i {
        font-size: 16px;
        font-weight: bold;
        position: absolute;
        top: 50%;
        right: 10px;
        transform: translateY(-50%);
        cursor: pointer;
    }

    .defaultClass {
        left: 68px;
    }

    .hiddenClass {
        left: calc(100% + 18px);
    }

    .leaveComments .detail_comment ul {
        height: calc(100% - 70px);
        padding: 0 0 0 10px;
        font-size: 12px;
        overflow: auto;
        padding-bottom: 30px;
        background: rgba(235, 150, 2, 0.1);
    }

    .leaveComments .detail_comment button {
        vertical-align: top;
        margin-top: 10px;
    }

    .leaveComments /deep/ .ivu-tooltip-light .ivu-tooltip-inner {
        font-size: 14px;
    }

    .leaveComments /deep/ .ivu-tooltip {
        width: 100%;
    }

    .detail_comment .textarea {
        padding: 0px 20px 0 10px;
        position: absolute;
        width: 100%;
        bottom: 0px;
        background: white;
        border-radius: 0px 0px 5px 5px;
    }

    .textarea > img {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%);
    }

    .detail_comment .textarea /deep/ textarea.ivu-input {
        resize: none;
        height: 40px;
        border: none;
        padding-top: 10px;
    }

    .detail_comment .textarea /deep/ textarea.ivu-input:focus {
        box-shadow: none;
    }

    .detail_comment p {
        width: 250px;
        font-size: 12px;
        box-shadow: 0 4px 6px 2px #eaebee;
        border-radius: 5px;
        margin: 10px 0 0;
        position: relative;
        min-height: 36px;
        background-color: white;
        padding: 5px 10px;
    }

    .detail_comment p::before {
        content: '';
        position: absolute;
        width: 0;
        height: 0;
        top: -6px;
        border-style: solid;
        border-width: 6px;
        border-color: transparent transparent #fff #fff;
        transform: rotate(135deg);
        -webkit-box-shadow: -2px 2px 3px 0 #eaebee;
        -moz-box-shadow: -2px 2px 3px 0 #eaebee;
        box-shadow: -2px 2px 4px 0 #eaebee;
    }

    .detail_comment p.other::before {
        left: 15px;
    }

    .detail_comment p.self::before {
        right: 15px;
    }

    .submit {
        margin: 25px 0;
        text-align: center;
    }

    /* .submit /deep/  .ivu-btn-success {
        width: 100px;
        height: 30px;

    } */

    .w400 {
        width: 400px;
    }

    .sliderList /deep/ .ivu-form-item-error-tip {
        top: 80%;
    }

    .sliderList {
        padding-top: 30px;
        max-height: 450px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .scheduleTitle {
        padding-left: 30px;
        line-height: 20px;
        font-size: 14px;
    }

    .scheduleTitle span.curScheStyle {
        color: #0D8EF5;
    }

    .footer {
        position: fixed;
        height: 60px;
        background-color: white;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 99;
    }

    .footer .footer_content {
        max-width: 1600px;
        min-width: 1200px;
        margin: auto;
        height: 100%;
        line-height: 60px;
        padding: 0 16px;
        text-align: right;

    }

    .footer .footer_content > p > button {
        height: 30px;
        font-size: 12px;
        text-align: center;
    }

    .footer .footer_content > p > button.submitBtn {
        margin-left: 10px;
    }

    .fixed_nav {
        width: 45px;
        background-color: #EE9820;
        border-radius: 30px;
        position: fixed;
        right: 20px;
        bottom: 100px;
        padding: 20px 0px;
    }

    .fixed_nav ul li {
        color: white;
        cursor: pointer;
        position: relative;
        padding: 5px 10px;
    }

    .fixed_nav ul li:hover {
        background-color: #FECB84;
    }

    .fixed_nav ul li:last-child {
        margin: 0;
    }

    .fixed_nav ul li img {
        width: 25px;
        display: block;
    }

    .fixed_nav ul li a {
        height: 100%;
        color: white;
    }

    .fixed_nav .login-qr img {
        margin: auto;
        width: 100px;
        height: 100px;
    }

    .fixed_nav .login-qr {
        padding: 15px;
        width: 200px;
        background: #FFFBF5;
        border: 2px solid #EB9620;
        border-radius: 4px;
    }

    .fixed_nav .login-qr-box {
        position: absolute;
        will-change: top, left;
        top: 0;
        left: 0;
        transform: translate(-100%, -50%);
        margin-left: -35px;
        transition: all .5s linear;
        z-index: 100;
        margin-top: 24px;
    }

    .fixed_nav .login-qr-box::before {
        content: '';
        display: block;
        position: absolute;
        border: 8px solid transparent;
        border-left-color: #FFFBF5;
        right: -14px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 12;
    }

    .fixed_nav .login-qr-box::after {
        content: '';
        display: block;
        position: absolute;
        border: 10px solid transparent;
        border-left-color: #EB9620;
        top: 50%;
        right: -18px;
        transform: translateY(-50%);
        z-index: 10;
    }

    .fixed_nav .login-qr .qr-title {
        font-size: 12px;
        color: #666;
        line-height: 20px
    }

    .login-qr .qq-btn button {
        width: 90%;
        margin-top: 15px;
        border-radius: 12px;
    }

</style>
